#!/usr/bin/python

import os
import time

source_file="/root/bak/"
#format_source_file=source_file.split("/")[-1]

backup_file="/data/backup/"

date=time.strftime("%Y%m%d%H%M%S",time.localtime())
command = "tar -czvf %s%s.tar.gz  %s" %(backup_file,date,source_file)
path=("%s%s.tar.gz") %(backup_file,date)
if os.system(command) == 0:
        print "backup successful && %s" %path
else:
        print "backup failed,Please login and check the scripts."